﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace ComputedTable.Version10
{
    public class RowResolver<TRowId> : IRowResolver<TRowId>
    {
        public RowResolver(IList<TRowId> rows)
        {
            this.Ids = rows;
        }

        public int IndexOf(TRowId row)
        {
            return this.Ids.IndexOf(row);
        }

        public int Count { get { return this.Ids.Count(); } }

        public IList<TRowId> Ids { get; private set; }

        public int IndexOfPrevious(TRowId rowId)
        {
            return Math.Max(this.IndexOf(rowId) - 1, -1);
        }
    }
}
